package priv.pattern.iteratorpattern.setvice.impl;

import priv.pattern.iteratorpattern.pojo.Student;
import priv.pattern.iteratorpattern.setvice.Aggregate;
import priv.pattern.iteratorpattern.setvice.Iterator;

import java.util.ArrayList;
import java.util.List;

/*
 * 作者：m鹏h
 * 时间；2024/8/7 23:02
 * 描述：
 **/
public class Classroom implements Aggregate {

 private List<Student> students;

 public Classroom(){
  students = new ArrayList<>();
 }

 public void addStudent(Student student){
  students.add(student);
 }

 public Student getStudentAt(int index){
  return  students.get(index);

 }

 public int getSize(){
  return students.size();
 }
 @Override
 public Iterator createIterator() {
  return new ClassroomIterator(this);
 }
}
